package cn.hchaojie.camp.week1;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class NumberGame extends Application {
	private int state = 1;			// 1:结束  2：正在猜 3：猜中了
	private int currentGuess = -1;

	@Override
	public void start(Stage primaryStage) throws Exception {
		HBox container = new HBox(10);
		container.setAlignment(Pos.CENTER);
		
		Label guess = new Label("?");
		guess.setMinWidth(80);
		TextField textField = new TextField();
		Button button = new Button("来一局");
		button.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				if (state == 1) {
					state = 2;		// 正在猜
					button.setText("猜一猜");
				} else if (state == 2) {
					
				}
			}
		});
		Label message = new Label();
		
		container.getChildren().addAll(guess, textField, button, message);

		Scene scene = new Scene(container, 600, 300);
		primaryStage.setScene(scene);

		primaryStage.show();
	}
	
	public static void main(String[] args) {
		launch(args);
	}
}
